/*
 * FormElement.h
 *
 *  Created on: 2010-6-5
 *      Author: Guobc
 */

#ifndef FORMELEMENT_H_
#define FORMELEMENT_H_

#include "CommonElement.h"

namespace HA {
class FormElement: public HA::CommonElement {

public:
	FormElement();

	/**
	 * Get the set of names handles by this element.
	 * @return The names to be matched that create elements of this type.
	 */
	inline string* getIds() const {
		return mIds;
	}

	/**
	 * Return the set of name that cause this element to finish.
	 * @return The names of following elements that stop further parse.
	 */
	inline string* getEnders() const {
		return mEnds;
	}

	/**
	 * Allow creating an instance of this node.
	 * @return A new instance of this node.
	 */
	inline ASTNode* newInstance() const {
		return new FormElement();
	}

	/**
	 * Modify a new location to this form element.
	 * @param location The new location url.
	 */
	inline void setFormLoaction(const string& location) {
		mFormLocation = location;
		setAttribute("ACTION", location);
	}
	/**
	 * Get the value of the action attribute.
	 * @return The submit url of the form.
	 */
	inline string getFormLocation() {
		return mFormLocation == "" ? getAttribute("ACTION") : mFormLocation;
	}

	/**
	 * Get the value of the method attribute.
	 * @return The method of form.
	 */
	inline string getFormMethod() {
		return getAttribute("METHOD");
	}

private:
	static string mIds[];
	static string mEnds[];
	string mFormLocation;
};
}

#endif /* FORMELEMENT_H_ */
